<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">

<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="body">
			<h:form onkeypress="if (event.keyCode == 13) return false;">

				<rich:notifyMessages stayTime="2000" nonblocking="true" />

				<table>
					<tr>
						<td>
							<h:outputText value="#{msg.building_name}" styleClass="outputText" style="font-size: 16px;" />
						</td>
						
						<td>
							<h:selectOneMenu 
								id="search_building_name" styleClass="short_selectClass" 
								value="#{realTimeManageBean.selectedBuildingId}" valueChangeListener="#{realTimeManageBean.buildingValueChanged}" >
								<f:selectItems value="#{realTimeManageBean.buildingOptions}" />
								<a4j:ajax event="valueChange" render="search_floor_name" execute="@this" />

							</h:selectOneMenu>
						</td>
						
						<td>
							<h:outputText value="&#160;" />
							<h:outputText value="&#160;" />
							<h:outputText value="&#160;" />
						</td>
											
						<td>
							<h:outputText value="#{msg.floor_name}" styleClass="outputText" style="font-size: 16px;" />
						</td>
						
						<td>
							<h:selectOneMenu 
								id="search_floor_name" styleClass="short_selectClass" 
								value="#{realTimeManageBean.selectedFloorId}" valueChangeListener="#{realTimeManageBean.floorValueChanged}" >
								<f:selectItems value="#{realTimeManageBean.floorOptions}" />
								<a4j:ajax event="valueChange" render="search_room_name" execute="@this" />
							</h:selectOneMenu>
						</td>
						
						<td>
							<h:outputText value="&#160;" />	
							<h:outputText value="&#160;" />
							<h:outputText value="&#160;" />
						</td>
											
						<td>
							<h:outputText value="#{msg.room_name}" styleClass="outputText" style="font-size: 16px;" />
						</td>
						<td>
							<h:selectOneMenu 
								id="search_room_name" styleClass="short_selectClass" 
								value="#{realTimeManageBean.selectedRoomId}" valueChangeListener="#{realTimeManageBean.roomValueChanged}" >
								<f:selectItems value="#{realTimeManageBean.roomOptions}" />
								<a4j:ajax event="valueChange" render="send_btn" execute="@this" />
							</h:selectOneMenu>
						</td>
						
						<td>
							<h:outputText value="&#160;" />
							<h:outputText value="&#160;" />
							<h:outputText value="&#160;" />
						</td>
					
						<td>
							<a4j:commandButton 
								styleClass="buttonClass" style="font-size: 16px;" 
								value="#{msg.search}" action="#{realTimeManageBean.search}" 
								render="@form" />
						</td>
					</tr>
				</table>
				
				<rich:accordion switchType="client">
					<rich:accordionItem header="#{msg.real_time_status}" style="font-size: 16px;">
						<table>
							<tr>
								<td>
									<rich:extendedDataTable 
										id="dataTable" width="100%" rows="15" frozenColumns="2"
										value="#{realTimeManageBean.realTimeControls}" var="realTimeControl" iterationStatusVar="it">
										
										<f:facet name="noData">
								        	<h:outputText value="#{msg.no_record_found}" />
								        </f:facet>	
										 								
										<rich:column width="30px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.index_logo}" />
								            </f:facet>						 
											<h:outputText value="#{it.index + 1}" />						
										</rich:column>
										
										<rich:column width="200px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.machine_name}" />
								            </f:facet>						 
											<h:outputText value="#{realTimeControl.machine.machineName}" />						
										</rich:column>
										
										<rich:column width="120px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.start_option}" />
								            </f:facet>						 
											<h:outputText value="#{msg.start_on}" rendered="#{realTimeControl.start}" />						
											<h:outputText value="#{msg.start_off}" rendered="#{!realTimeControl.start}" />
										</rich:column>
										
										<rich:column width="120px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.temperature}(#{msg.celsius})" />
								            </f:facet>						 
											<h:outputText value="#{realTimeControl.temperature}" />						
										</rich:column>
										
										<rich:column width="120px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.wind_value}" />
								            </f:facet>						 
											<h:outputText value="#{realTimeControl.windValue}" />						
										</rich:column>
										
										<rich:column width="120px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.fan_speed}" />
								            </f:facet>						 
											<h:outputText value="#{msg.fan_speed_auto}" rendered="#{realTimeControl.fanSpeed == 0}" />		
											<h:outputText value="#{msg.fan_speed_high}" rendered="#{realTimeControl.fanSpeed == 1}" />
											<h:outputText value="#{msg.fan_speed_mid}" rendered="#{realTimeControl.fanSpeed == 2}" />
											<h:outputText value="#{msg.fan_speed_low}" rendered="#{realTimeControl.fanSpeed == 3}" />				
										</rich:column>
										
										<rich:column width="120px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.control_mode}" />
								            </f:facet>						 
											<h:outputText value="#{msg.control_mode_auto}" />						
										</rich:column>
										
										<rich:column width="120px" style="text-align: center;">
											<f:facet name="header">
								                <h:outputText value="#{msg.unmonitored}" />
								            </f:facet>						 
											<h:outputText value="#{msg.unmonitored_on}" />						
										</rich:column>
										
									</rich:extendedDataTable>
								</td>
							</tr>
						</table>
					</rich:accordionItem>
					
					<rich:accordionItem header="#{msg.real_time_command}" style="font-size: 16px;">
						<table>
							<tr>
								<td>
									<h:outputText value="#{msg.start_option}" styleClass="outputText" style="font-size: 16px;" />
									<h:outputText value="&#160;" />	
								</td>
								<td>
									<h:selectOneMenu 
										styleClass="short_selectClass" value="#{realTimeManageBean.realTimeControl.start}" >									
										<f:selectItem itemLabel="#{msg.start_on}" itemValue="#{true}" />
										<f:selectItem itemLabel="#{msg.start_off}" itemValue="#{false}" />
									</h:selectOneMenu>
								</td>
								
								<td>
									<h:outputText value="&#160;" />	
									<h:outputText value="&#160;" />	
									<h:outputText value="&#160;" />	
								</td>
								
								<td>
									<h:outputText value="#{msg.fan_speed}" styleClass="outputText" style="font-size: 16px;" />
									<h:outputText value="&#160;" />	
								</td>
								
								
								<td>
									<h:selectOneMenu 
										styleClass="short_selectClass" value="#{realTimeManageBean.realTimeControl.fanSpeed}" >									
										<f:selectItem itemLabel="#{msg.fan_speed_auto}" itemValue="#{0}" />
										<f:selectItem itemLabel="#{msg.fan_speed_high}" itemValue="#{1}" />
										<f:selectItem itemLabel="#{msg.fan_speed_mid}" itemValue="#{2}" />
										<f:selectItem itemLabel="#{msg.fan_speed_low}" itemValue="#{3}" />
										
									</h:selectOneMenu>
								</td>
								
								<td>
								</td>
								
							</tr>
							
							<tr>
								<td>
									<h:outputText value="#{msg.temperature}(#{msg.celsius})" styleClass="outputText" style="font-size: 16px;" />
									<h:outputText value="&#160;" />	
								</td>
								<td>
									<h:selectOneMenu 
										styleClass="short_selectClass" value="#{realTimeManageBean.realTimeControl.temperature}" >									
										<f:selectItems value="#{realTimeManageBean.temperatureOptions}" />
									</h:selectOneMenu>
								</td>
								
								<td>
									<h:outputText value="&#160;" />	
									<h:outputText value="&#160;" />	
									<h:outputText value="&#160;" />	
								</td>
								
								<td>
									<h:outputText value="#{msg.wind_value}" styleClass="outputText" style="font-size: 16px;" />
									<h:outputText value="&#160;" />	
								</td>
								
								
								<td>
									<h:selectOneMenu 
										styleClass="short_selectClass" value="#{realTimeManageBean.realTimeControl.windValue}" >									
										<f:selectItems value="#{realTimeManageBean.windValueOptions}" />
										
									</h:selectOneMenu>
								</td>
								
								<td>
								</td>
							</tr>
							
							<tr>
								<td>
									<h:outputText value="#{msg.control_mode})" styleClass="outputText" style="font-size: 16px;" />
									<h:outputText value="&#160;" />	
								</td>
								<td>
									<h:selectOneMenu 
										styleClass="short_selectClass" value="#{realTimeManageBean.realTimeControl.controlMode}" >									
										<f:selectItem itemLabel="#{msg.control_mode_auto}" itemValue="Auto" />
									</h:selectOneMenu>
								</td>
								
								<td>
									<h:outputText value="&#160;" />	
									<h:outputText value="&#160;" />	
									<h:outputText value="&#160;" />	
								</td>
								
								<td>
									<h:outputText value="#{msg.unmonitored}" styleClass="outputText" style="font-size: 16px;" />
									<h:outputText value="&#160;" />	
								</td>
								
								
								<td>
									<h:selectOneMenu 
										styleClass="short_selectClass" value="#{realTimeManageBean.realTimeControl.unmonitored}" >									
										<f:selectItem itemLabel="#{msg.unmonitored_on}" itemValue="#{on}" />
										<f:selectItem itemLabel="#{msg.unmonitored_on}" itemValue="#{off}" />
									</h:selectOneMenu>
								</td>
								
								<td>
									<a4j:commandButton 
										id="send_btn"
										styleClass="buttonClass" style="font-size: 16px;" 
										value="#{msg.apply}" action="#{realTimeManageBean.send}" 
										render="@form" rendered="#{realTimeManageBean.allowControl}"/>

								</td>
								
							</tr>
						</table>
					</rich:accordionItem>
					
				</rich:accordion>

			</h:form>

		</ui:define>
	</ui:composition>
</body>
</html>
